/*
 * @Description: 
 * @Author: 胡涛
 * @Date: 2023-12-10 12:41:37
 * @LastEditors: 胡涛
 * @LastEditTime: 2023-12-10 21:20:39
 */
const formatterOptions = [{
    type: 'default',
    name: "默认格式",
    defaultArgs: {},
    formatter: (args: Record<string, string>) => {
        return "";
    },
}, {
    type: 'string',
    name: "文本格式化",
    defaultArgs: { prefix: "", suffix: "" },
    formatter: (args: Record<string, any>) => {
        let { prefix, suffix } = args;
        return `return "${prefix || ''}" + value + "${suffix || ''}";`;
    },
}, {
    type: 'json',
    name: "JSON对象格式",
    defaultArgs: {},
    formatter: (args: Record<string, any>) => {
        return `return value;`;
    },
}, {
    type: 'number',
    name: "数值类型格式",
    defaultArgs: { precision: 2, prefix: '￥', suffix: '' },
    formatter: (args: Record<string, any>) => {
        let { precision, prefix, suffix } = args;
        if (precision > 0) {
            let arrs = [
                `let dataValue = value.toFixed(${precision});`,
                `return "${prefix || ''}" + value + "${suffix || ''}";`
            ]
            return arrs.join("\r\n");
        }
        return `return "${prefix || ''}" + value + "${suffix || ''}";`;
    },
}, {
    type: 'date',
    name: "日期类型格式",
    defaultArgs: { valueFormat: 'YYYY-MM-DD HH:mm:ss' },
    formatter: (args: Record<string, any>) => {
        let { valueFormat } = args;

        let arrs = [
            `if(value){`,
            `    return $app.formatDate(value,"${valueFormat}");`,
            '}',
            'else{',
            '    return "--"',
            '}'
        ]
        return arrs.join("\r\n");
    }
},
{
    type: 'boolean',
    name: "布尔值格式",
    defaultArgs: { trueValue: '是', falseValue: '否' },
    formatter: (args: Record<string, any>) => {
        let { trueValue, falseValue } = args;
        return `return value ? "${trueValue}" : "${falseValue}"; `;
    },
}, {
    type: 'enum',
    name: "枚举格式",
    defaultArgs: { name: 'TestEnum' },
    formatter: (args: Record<string, any>) => {
        let { name } = args
        return `return $app.enumName("${name}",value);`;
    },
}, {
    type: 'dictionary',
    name: "数据字典格式",
    defaultArgs: { name: 'TestDictionary' },
    formatter: (args: Record<string, string>) => {
        let { name } = args
        return `return $app.dictionaryName("${name}",value);`;

    },
}, {
    type: 'user',
    name: "用户名称格式",
    defaultArgs: {},
    formatter: (args: Record<string, string>) => {
        return `return $app.userName(value);`;
    },
}, {
    type: 'organize',
    name: "机构名称格式",
    defaultArgs: {},
    formatter: (args: Record<string, string>) => {
        return `return $app.organizeName(value);`;
    },
}, {
    type: 'enterprise',
    name: "企业名称格式",
    defaultArgs: {},
    formatter: (args: Record<string, string>) => {
        return `return $app.enterpriseName(value);`;
    },
}, {
    type: 'region',
    name: "行政区划格式",
    defaultArgs: {},
    formatter: (args: Record<string, string>) => {
        return `return $app.areaName(value);`;
    },
}, {
    type: 'project',
    name: "项目名称格式",
    defaultArgs: {},
    formatter: (args: Record<string, string>) => {
        return `return $app.projectName(value);`;
    },
}, {
    type: 'custom',
    name: "自定义格式化",
    defaultArgs: {},
    formatter: (args: Record<string, string>) => {
        return "return value;";
    },
}]

export {
    formatterOptions
}